package com.hong.service_product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hong.fy_common_commomutil.common.result.Result;
import com.hong.fy_model.model.review.ReviewEntity;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.hong.service_product.mapper.ReviewMapper;
import com.hong.service_product.service.ReviewService;

import java.util.List;


@Service("reviewService")
public class ReviewServiceImpl extends ServiceImpl<ReviewMapper, ReviewEntity> implements ReviewService {

    //用户评论接口
    @Override
    public Boolean reply(ReviewEntity review) {
        boolean flag = this.save(review);
        return flag;
    }

    @Override
    public Boolean deleteReview(String reviewId) {
        boolean flag = this.removeById(reviewId);
        return flag;
    }

    @Override
    public IPage<ReviewEntity> listByProductId(String productId, Integer pageNum, Integer limit) {
        Page page = new Page(pageNum, limit);
        LambdaQueryWrapper<ReviewEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(ReviewEntity::getProductId, productId);
        IPage<ReviewEntity> iPage = this.page(page, queryWrapper);
        return iPage;
    }

    //评论点赞接口
    @Override
    public Boolean like(String reviewId) {
        return null;
    }
}